home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 55373 / 55373.xpi / components / btClientService.js next >
Text File  |  2010-01-26  |  3KB  |  74 lines

  1. /* If you are upgrading from toolbar to boom, use a new CLSID and change 1 to 2 */
  2. const BT_SHORTNAME = "rangersfc";
  3. const BT_CLSID      = Components.ID('{d72f6c4a-de6f-4eaf-bad3-6f9259cae9a9}');
  4.  
  5. const BT_CONTRACTID = "@mozilla.org/bt-service-" + BT_SHORTNAME + ";1";
  6.  
  7. const Cc = Components.classes;
  8. const Ci = Components.interfaces;
  9. const Cr = Components.results;
  10.  
  11. const gPrefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
  12. const gPrefBranch = gPrefService.getBranch(null).QueryInterface(Ci.nsIPrefBranch2);
  13. const gObserver = Cc['@mozilla.org/observer-service;1'].getService(Ci.nsIObserverService);
  14. const gScriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
  15. const gConsoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);   
  16.  
  17. Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
  18.  
  19. function BTHandler() {
  20. }
  21.  
  22. BTHandler.prototype = {
  23.   brandObject: null,
  24.   observe: function(aSubject, aTopic, aData) {
  25.     switch(aTopic) {
  26.       case "app-startup":
  27.         gObserver.addObserver(this,"xpcom-shutdown",false);
  28.         gObserver.addObserver(this,"profile-after-change",false);
  29.         gObserver.addObserver(this,"profile-before-change",false);
  30.         gObserver.addObserver(this,"final-ui-startup",false);
  31.         gScriptLoader.loadSubScript("chrome://" + BT_SHORTNAME + "boom/content/btServiceUtilities.js", this);
  32.         gScriptLoader.loadSubScript("chrome://" + BT_SHORTNAME + "boom/content/btClient.js");
  33.         /* Use the first client in the Brandthunder.clients array */
  34.         for (client in BrandThunder.clients) {
  35.           this.brandObject = BrandThunder.clients[client];
  36.           break;
  37.         }
  38.         break;
  39.       case "xpcom-shutdown":
  40.         gObserver.removeObserver(this,"xpcom-shutdown");
  41.         gObserver.removeObserver(this,"profile-after-change");
  42.         gObserver.removeObserver(this,"profile-before-change");
  43.         gObserver.removeObserver(this,"final-ui-startup");
  44.         break;
  45.       case "profile-after-change":
  46.         this.profileAfterChange(this.brandObject);
  47.         this.firstRun(this.brandObject);
  48.         break;
  49.       case "profile-before-change":
  50.         this.profileBeforeChange(this.brandObject);
  51.         break;
  52.       case "final-ui-startup":
  53.         this.finalUIStartup(this.brandObject);
  54.         break;
  55.     }
  56.   },
  57.   log: function(string) {
  58.     gConsoleService.logStringMessage(string);
  59.   },
  60.  
  61.   classDescription: "BT Service " + BT_SHORTNAME,
  62.   contractID: BT_CONTRACTID,
  63.   classID: BT_CLSID,
  64.   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
  65.   _xpcom_categories: [{
  66.     category: "app-startup",
  67.     service: true
  68.   }]
  69. }
  70.  
  71. function NSGetModule(compMgr, fileSpec) {
  72.   return XPCOMUtils.generateModule([BTHandler]);
  73. }
  74.